<?php
class sfWidgetFormSchemaFormatterCustom extends sfWidgetFormSchemaFormatter
{
    protected $requiredFields = array();
    public function setRequiredFields(array $requiredFields = array())
    {
        $this->requiredFields = $requiredFields;
    }
    protected
    $required = '<span class="required"> *</span>',
    $rowFormat = '<div class="field">
                    <div class="lbl">%label%</div>
                    %field% %help% %error%
                  </div>',

    $helpFormat = '<a href="#" class="tip" oldtitle="%help%" aria-describedby="ui-tooltip-0">
                      <img alt="" src="images/hint_icon.png">
                   </a>',
    $labelFormat = '%label%',
    $errorRowFormatInARow = '<p class="error_msg">%error%</p>',
    $errorRowFormat = '%errors%',
    $namedErrorRowFormatInARow = "<li><b>%name%:</b> %error%</li>\n",
    $errorListFormatInARow = '<ul class="error_list">%errors%</ul>',
    $decoratorFormat = '<div class="form">\n  %content%</div>'
    ;

    public function generateLabel($name, $attributes = array())
    {
        $label = parent::generateLabel($name, $attributes);
        if(array_search($name, $this->requiredFields) !== false)
            $label .= $this->required;

        return $label;
    }
}
